```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Java类型系统详解 | 技术小馆</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.6;
        }
        .hero {
            background: linear-gradient(135deg, #6e8efb, #a777e3);
        }
        .card {
            transition: all 0.3s ease;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }
        .card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
        }
        .type-card {
            border-left: 4px solid;
        }
        .primitive {
            border-left-color: #4f46e5;
        }
        .reference {
            border-left-color: #10b981;
        }
        .highlight {
            background: linear-gradient(90deg, rgba(79, 70, 229, 0.1), transparent);
            padding: 0.5rem 1rem;
            border-radius: 0.25rem;
        }
        .drop-cap:first-letter {
            font-size: 3.5em;
            float: left;
            line-height: 0.7;
            margin-right: 0.2em;
            margin-top: 0.1em;
            color: #4f46e5;
            font-weight: bold;
        }
        .footer-link {
            transition: all 0.2s ease;
        }
        .footer-link:hover {
            color: #a5b4fc;
            transform: translateX(3px);
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="hero text-white py-20 px-4 md:px-0">
        <div class="container mx-auto max-w-5xl">
            <div class="flex flex-col md:flex-row items-center">
                <div class="md:w-1/2 mb-10 md:mb-0">
                    <h1 class="text-4xl md:text-5xl font-bold mb-4 font-serif">Java类型系统解析</h1>
                    <p class="text-xl mb-6 opacity-90">深入理解基本类型与引用类型的核心差异</p>
                    <div class="flex space-x-4">
                        <span class="px-4 py-2 bg-white bg-opacity-20 rounded-full text-sm">#Java基础</span>
                        <span class="px-4 py-2 bg-white bg-opacity-20 rounded-full text-sm">#内存管理</span>
                        <span class="px-4 py-2 bg-white bg-opacity-20 rounded-full text-sm">#编程基础</span>
                    </div>
                </div>
                <div class="md:w-1/2">
                    <div class="bg-white bg-opacity-10 p-6 rounded-xl backdrop-blur-sm">
                        <div class="mermaid">
                            graph TD
                                A[Java数据类型] --> B[基本类型]
                                A --> C[引用类型]
                                B --> D[整数类型]
                                B --> E[浮点类型]
                                B --> F[字符类型]
                                B --> G[布尔类型]
                                C --> H[类Class]
                                C --> I[接口Interface]
                                C --> J[数组Array]
                                C --> K[枚举Enum]
                                C --> L[注解Annotation]
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <main class="container mx-auto max-w-5xl px-4 md:px-0 py-12">
        <!-- Introduction -->
        <section class="mb-16">
            <div class="bg-white rounded-xl shadow-sm p-8 card">
                <p class="text-lg leading-relaxed drop-cap">
                    在Java中，类型系统是整个语言的基础架构，它决定了数据的存储方式和操作规则。类型分为两大类：<span class="font-bold text-indigo-600">基本类型</span>（Primitive Types）和<span class="font-bold text-emerald-600">引用类型</span>（Reference Types）。这两种类型的区别在于内存分配、数据存储以及操作方式。
                </p>
                <div class="grid md:grid-cols-2 gap-6 mt-8">
                    <div class="p-6 rounded-lg type-card primitive">
                        <div class="flex items-center mb-4">
                            <i class="fas fa-cube text-indigo-500 text-2xl mr-3"></i>
                            <h3 class="text-xl font-bold text-indigo-700">基本类型</h3>
                        </div>
                        <p class="text-gray-700">直接存储在栈内存中，包含实际值，性能高但功能有限。包含8种具体类型，分为整数、浮点、字符和布尔四大类。</p>
                    </div>
                    <div class="p-6 rounded-lg type-card reference">
                        <div class="flex items-center mb-4">
                            <i class="fas fa-project-diagram text-emerald-500 text-2xl mr-3"></i>
                            <h3 class="text-xl font-bold text-emerald-700">引用类型</h3>
                        </div>
                        <p class="text-gray-700">存储在堆内存中，通过引用来访问对象，功能丰富但性能开销略大。包括类、接口、数组、枚举和注解等。</p>
                    </div>
                </div>
            </div>
        </section>

        <!-- Primitive Types Section -->
        <section class="mb-16">
            <div class="flex items-center mb-8">
                <div class="w-12 h-12 bg-indigo-100 rounded-lg flex items-center justify-center mr-4">
                    <i class="fas fa-cube text-indigo-600 text-xl"></i>
                </div>
                <h2 class="text-3xl font-bold text-gray-800 font-serif">1. 基本类型（Primitive Types）</h2>
            </div>
            <div class="bg-white rounded-xl shadow-sm p-8 card">
                <p class="text-gray-700 mb-6">基本类型是Java中最基础的数据类型，它们直接存储在栈内存中，且每种类型都对应着固定的内存大小。Java提供了8种基本类型，分为四大类：</p>
                
                <!-- Integer Types -->
                <div class="mb-8">
                    <h3 class="text-xl font-bold text-gray-800 mb-4 flex items-center">
                        <span class="w-8 h-8 bg-indigo-100 text-indigo-600 rounded-full flex items-center justify-center mr-3">1</span>
                        整数类型（Integer Types）
                    </h3>
                    <div class="overflow-x-auto">
                        <table class="min-w-full bg-white rounded-lg overflow-hidden">
                            <thead class="bg-indigo-50">
                                <tr>
                                    <th class="py-3 px-4 text-left text-indigo-600">类型</th>
                                    <th class="py-3 px-4 text-left text-indigo-600">字节数</th>
                                    <th class="py-3 px-4 text-left text-indigo-600">位数</th>
                                    <th class="py-3 px-4 text-left text-indigo-600">取值范围</th>
                                </tr>
                            </thead>
                            <tbody class="divide-y divide-gray-200">
                                <tr>
                                    <td class="py-3 px-4 font-mono font-bold">byte</td>
                                    <td class="py-3 px-4">1</td>
                                    <td class="py-3 px-4">8</td>
                                    <td class="py-3 px-4">-128 到 127</td>
                                </tr>
                                <tr class="bg-gray-50">
                                    <td class="py-3 px-4 font-mono font-bold">short</td>
                                    <td class="py-3 px-4">2</td>
                                    <td class="py-3 px-4">16</td>
                                    <td class="py-3 px-4">-32,768 到 32,767</td>
                                </tr>
                                <tr>
                                    <td class="py-3 px-4 font-mono font-bold">int</td>
                                    <td class="py-3 px-4">4</td>
                                    <td class="py-3 px-4">32</td>
                                    <td class="py-3 px-4">-2<sup>31</sup> 到 2<sup>31</sup>-1</td>
                                </tr>
                                <tr class="bg-gray-50">
                                    <td class="py-3 px-4 font-mono font-bold">long</td>
                                    <td class="py-3 px-4">8</td>
                                    <td class="py-3 px-4">64</td>
                                    <td class="py-3 px-4">-2<sup>63</sup> 到 2<sup>63</sup>-1</td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
                
                <!-- Floating-Point Types -->
                <div class="mb-8">
                    <h3 class="text-xl font-bold text-gray-800 mb-4 flex items-center">
                        <span class="w-8 h-8 bg-indigo-100 text-indigo-600 rounded-full flex items-center justify-center mr-3">2</span>
                        浮点类型（Floating-Point Types）
                    </h3>
                    <div class="grid md:grid-cols-2 gap-6">
                        <div class="bg-indigo-50 p-6 rounded-lg">
                            <h4 class="font-mono font-bold text-lg text-indigo-700 mb-2">float</h4>
                            <p class="text-gray-700">占用4字节（32位），单精度浮点数。</p>
                            <p class="text-sm text-indigo-600 mt-2">示例：<code class="bg-indigo-100 px-2 py-1 rounded">float f = 3.14f;</code></p>
                        </div>
                        <div class="bg-indigo-50 p-6 rounded-lg">
                            <h4 class="font-mono font-bold text-lg text-indigo-700 mb-2">double</h4>
                            <p class="text-gray-700">占用8字节（64位），双精度浮点数。</p>
                            <p class="text-sm text-indigo-600 mt-2">示例：<code class="bg-indigo-100 px-2 py-1 rounded">double d = 3.141592653589793;</code></p>
                        </div>
                    </div>
                </div>
                
                <!-- Character Type -->
                <div class="mb-8">
                    <h3 class="text-xl font-bold text-gray-800 mb-4 flex items-center">
                        <span class="w-8 h-8 bg-indigo-100 text-indigo-600 rounded-full flex items-center justify-center mr-3">3</span>
                        字符类型（Character Type）
                    </h3>
                    <div class="bg-indigo-50 p-6 rounded-lg">
                        <h4 class="font-mono font-bold text-lg text-indigo-700 mb-2">char</h4>
                        <p class="text-gray-700">占用2字节（16位），用于存储一个Unicode字符，取值范围为0到65,535。</p>
                        <p class="text-sm text-indigo-600 mt-2">示例：<code class="bg-indigo-100 px-2 py-1 rounded">char c = 'A';</code> 或 <code class="bg-indigo-100 px-2 py-1 rounded">char c = '\u0041';</code></p>
                    </div>
                </div>
                
                <!-- Boolean Type -->
                <div>
                    <h3 class="text-xl font-bold text-gray-800 mb-4 flex items-center">
                        <span class="w-8 h-8 bg-indigo-100 text-indigo-600 rounded-full flex items-center justify-center mr-3">4</span>
                        布尔类型（Boolean Type）
                    </h3>
                    <div class="bg-indigo-50 p-6 rounded-lg">
                        <h4 class="font-mono font-bold text-lg text-indigo-700 mb-2">boolean</h4>
                        <p class="text-gray-700">表示布尔值，只有两个取值：<code class="bg-indigo-100 px-1 py-0.5 rounded">true</code> 和 <code class="bg-indigo-100 px-1 py-0.5 rounded">false</code>。在Java中，<code class="bg-indigo-100 px-1 py-0.5 rounded">boolean</code>的具体存储大小未明确规定，但通常为1位。</p>
                        <p class="text-sm text-indigo-600 mt-2">示例：<code class="bg-indigo-100 px-2 py-1 rounded">boolean flag = true;</code></p>
                    </div>
                </div>
            </div>
        </section>

        <!-- Reference Types Section -->
        <section class="mb-16">
            <div class="flex items-center mb-8">
                <div class="w-12 h-12 bg-emerald-100 rounded-lg flex items-center justify-center mr-4">
                    <i class="fas fa-project-diagram text-emerald-600 text-xl"></i>
                </div>
                <h2 class="text-3xl font-bold text-gray-800 font-serif">2. 引用类型（Reference Types）</h2>
            </div>
            <div class="bg-white rounded-xl shadow-sm p-8 card">
                <p class="text-gray-700 mb-6">引用类型指向对象的内存地址，而不是直接存储数据本身。引用类型包括类、接口、数组、枚举等。</p>
                
                <!-- Class -->
                <div class="mb-8">
                    <h3 class="text-xl font-bold text-gray-800 mb-4 flex items-center">
                        <span class="w-8 h-8 bg-emerald-100 text-emerald-600 rounded-full flex items-center justify-center mr-3">1</span>
                        类（Class）
                    </h3>
                    <div class="bg-emerald-50 p-6 rounded-lg">
                        <p class="text-gray-700 mb-4"><span class="font-bold">类（Class）</span>是引用类型的一个主要类别，它定义了对象的结构和行为。通过类可以创建对象，每个对象都是类的一个实例。</p>
                        <div class="flex flex-wrap gap-3">
                            <span class="px-3 py-1 bg-white rounded-full text-sm font-mono">String</span>
                            <span class="px-3 py-1 bg-white rounded-full text-sm font-mono">ArrayList</span>
                            <span class="px-3 py-1 bg-white rounded-full text-sm font-mono">HashMap</span>
                            <span class="px-3 py-1 bg-white rounded-full text-sm font-mono">自定义类</span>
                        </div>
                        <div class="mt-4 p-4 bg-white rounded-lg">
                            <pre class="text-sm text-gray-800"><code>// 类定义示例
public class Person {
    private String name;
    private int age;
    
    // 构造方法、getter/setter等
}</code></pre>
                        </div>
                    </div>
                </div>
                
                <!-- Interface -->
                <div class="mb-8">
                    <h3 class="text-xl font-bold text-gray-800 mb-4 flex items-center">
                        <span class="w-8 h-8 bg-emerald-100 text-emerald-600 rounded-full flex items-center justify-center mr-3">2</span>
                        接口（Interface）
                    </h3>
                    <div class="bg-emerald-50 p-6 rounded-lg">
                        <p class="text-gray-700 mb-4"><span class="font-bold">接口（Interface）</span>定义了一组方法，这些方法可以被任何实现该接口的类实现。接口也是一种引用类型。</p>
                        <div class="flex flex-wrap gap-3">
                            <span class="px-3 py-1 bg-white rounded-full text-sm font-mono">List</span>
                            <span class="px-3 py-1 bg-white rounded-full text-sm font-mono">Runnable</span>
                            <span class="px-3 py-1 bg-white rounded-full text-sm font-mono">Serializable</span>
                            <span class="px-3 py-1 bg-white rounded-full text-sm font-mono">Comparable</span>
                        </div>
                        <div class="mt-4 p-4 bg-white rounded-lg">
                            <pre class="text-sm text-gray-800"><code>// 接口定义示例
public interface Drawable {
    void draw();  // 抽象方法
    default void resize() {  // 默认方法
        System.out.println("Resizing...");
    }
}</code></pre>
                        </div>
                    </div>
                </div>
                
                <!-- Array -->
                <div class="mb-8">
                    <h3 class="text-xl font-bold text-gray-800 mb-4 flex items-center">
                        <span class="w-8 h-8 bg-emerald-100 text-emerald-600 rounded-full flex items-center justify-center mr-3">3</span>
                        数组（Array）
                    </h3>
                    <div class="bg-emerald-50 p-6 rounded-lg">
                        <p class="text-gray-700 mb-4"><span class="font-bold">数组（Array）</span>是引用类型，它是一组相同类型数据的有序集合。数组本身在内存中存储的是一个指向实际数据的引用。</p>
                        <div class="flex flex-wrap gap-3">
                            <span class="px-3 py-1 bg-white rounded-full text-sm font-mono">int[]</span>
                            <span class="px-3 py-1 bg-white rounded-full text-sm font-mono">String[]</span>
                            <span class="px-3 py-1 bg-white rounded-full text-sm font-mono">double[]</span>
                            <span class="px-3 py-1 bg-white rounded-full text-sm font-mono">Object[]</span>
                        </div>
                        <div class="mt-4 p-4 bg-white rounded-lg">
                            <pre class="text-sm text-gray-800"><code>// 数组示例
int[] numbers = new int[5];  // 声明并初始化
numbers[0] = 10;  // 赋值

String[] names = {"Alice", "Bob", "Charlie"};  // 直接初始化</code></pre>
                        </div>
                    </div>
                </div>
                
                <!-- Enum -->
                <div class="mb-8">
                    <h3 class="text-xl font-bold text-gray-800 mb-4 flex items-center">
                        <span class="w-8 h-8 bg-emerald-100 text-emerald-600 rounded-full flex items-center justify-center mr-3">4</span>
                        枚举（Enum）
                    </h3>
                    <div class="bg-emerald-50 p-6 rounded-lg">
                        <p class="text-gray-700 mb-4"><span class="font-bold">枚举（Enum）</span>是一种特殊的类，表示一组固定的常量。枚举类型在Java中也是一种引用类型。</p>
                        <div class="mt-4 p-4 bg-white rounded-lg">
                            <pre class="text-sm text-gray-800"><code>// 枚举定义示例
public enum Day {
    SUNDAY, MONDAY, TUESDAY, 
    WEDNESDAY, THURSDAY, 
    FRIDAY, SATURDAY;
}

// 使用示例
Day today = Day.MONDAY;
if (today == Day.MONDAY) {
    System.out.println("今天是周一");
}</code></pre>
                        </div>
                    </div>
                </div>
                
                <!-- Annotation -->
                <div>
                    <h3 class="text-xl font-bold text-gray-800 mb-4 flex items-center">
                        <span class="w-8 h-8 bg-emerald-100 text-emerald-600 rounded-full flex items-center justify-center mr-3">5</span>
                        注解（Annotation）
                    </h3>
                    <div class="bg-emerald-50 p-6 rounded-lg">
                        <p class="text-gray-700 mb-4"><span class="font-bold">注解（Annotation）</span>本质上也是一种引用类型，用于提供元数据，用来修饰类、方法、变量等。</p>
                        <div class="flex flex-wrap gap-3">
                            <span class="px-3 py-1 bg-white rounded-full text-sm font-mono">@Override</span>
                            <span class="px-3 py-1 bg-white rounded-full text-sm font-mono">@Deprecated</span>
                            <span class="px-3 py-1 bg-white rounded-full text-sm font-mono">@SuppressWarnings</span>
                            <span class="px-3 py-1 bg-white rounded-full text-sm font-mono">自定义注解</span>
                        </div>
                        <div class="mt-4 p-4 bg-white rounded-lg">
                            <pre class="text-sm text-gray-800"><code>// 注解使用示例
@Override
public String toString() {
    return "This is an example";
}

@Deprecated
public void oldMethod() {
    // 过时的方法
}</code></pre>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Boxing and Unboxing -->
        <section class="mb-16">
            <div class="flex items-center mb-8">
                <div class="w-12 h-12 bg-purple-100 rounded-lg flex items-center justify-center mr-4">
                    <i class="fas fa-exchange-alt text-purple-600 text-xl"></i>
                </div>
                <h2 class="text-3xl font-bold text-gray-800 font-serif">3. 装箱和拆箱（Boxing and Unboxing）</h2>
            </div>
            <div class="bg-white rounded-xl shadow-sm p-8 card">
                <p class="text-gray-700 mb-6">Java中还有一个与类型相关的概念，即<span class="font-bold text-purple-600">装箱</span>（Boxing）和<span class="font-bold text-purple-600">拆箱</span>（Unboxing），这涉及基本类型与引用类型的转换。</p>
                
                <div class="grid md:grid-cols-2 gap-6">
                    <div class="bg-purple-50 p-6 rounded-lg">
                        <h3 class="text-xl font-bold text-purple-700 mb-4 flex items-center">
                            <i class="fas fa-box-open text-purple-600 mr-2"></i> 装箱（Boxing）
                        </h3>
                        <p class="text-gray-700">将基本类型转换为相应的包装类对象，如 <code class="bg-purple-100 px-1 py-0.5 rounded">int</code> 转换为 <code class="bg-purple-100 px-1 py-0.5 rounded">Integer</code>。</p>
                        <div class="mt-4 p-4 bg-white rounded-lg">
                            <pre class="text-sm text-gray-800"><code>// 手动装箱
Integer num = Integer.valueOf(42);

// 自动装箱 (Java 5+)
Integer num = 42;  // 编译器自动转换为 Integer.valueOf(42)</code></pre>
                        </div>
                    </div>
                    <div class="bg-purple-50 p-6 rounded-lg">
                        <h3 class="text-xl font-bold text-purple-700 mb-4 flex items-center">
                            <i class="fas fa-box text-purple-600 mr-2"></i> 拆箱（Unboxing）
                        </h3>
                        <p class="text-gray-700">将包装类对象转换为相应的基本类型，如 <code class="bg-purple-100 px-1 py-0.5 rounded">Integer</code> 转换为 <code class="bg-purple-100 px-1 py-0.5 rounded">int</code>。</p>
                        <div class="mt-4 p-4 bg-white rounded-lg">
                            <pre class="text-sm text-gray-800"><code>// 手动拆箱
int n = num.intValue();

// 自动拆箱 (Java 5+)
int n = num;  // 编译器自动转换为 num.intValue()</code></pre>
                        </div>
                    </div>
                </div>
                
                <div class="mt-8 bg-yellow-50 p-6 rounded-lg">
                    <h3 class="text-xl font-bold text-yellow-700 mb-3 flex items-center">
                        <i class="fas fa-exclamation-triangle text-yellow-600 mr-2"></i> 注意事项
                    </h3>
                    <ul class="list-disc pl-5 space-y-2 text-gray-700">
                        <li>自动装箱/拆箱是Java的语法糖，由编译器在编译阶段完成转换</li>
                        <li>频繁的装箱/拆箱操作可能会影响性能</li>
                        <li>包装类对象可能为<code class="bg-yellow-100 px-1 py-0.5 rounded">null</code>，拆箱时会导致<code class="bg-yellow-100 px-1 py-0.5 rounded">NullPointerException</code></li>
                        <li>包装类对象之间的比较应使用<code class="bg-yellow-100 px-1 py-0.5 rounded">equals()</code>而不是<code class="bg-yellow-100 px-1 py-0.5 rounded">==</code></li>
                    </ul>
                </div>
            </div>
        </section>

        <!-- Type Conversion -->
        <section>
            <div class="flex items-center mb-8">
                <div class="w-12 h-12 bg-blue-100 rounded-lg flex items-center justify-center mr-4">
                    <i class="fas fa-random text-blue-600 text-xl"></i>
                </div>
                <h2 class="text-3xl font-bold text-gray-800 font-serif">4. 类型转换</h2>
            </div>
            <div class="bg-white rounded-xl shadow-sm p-8 card">
                <p class="text-gray-700 mb-6">在Java中，不同类型之间可能需要进行类型转换：</p>
                
                <div class="grid md:grid-cols-2 gap-6">
                    <div class="bg-blue-50 p-6 rounded-lg">
                        <h3 class="text-xl font-bold text-blue-700 mb-4 flex items-center">
                            <i class="fas fa-arrow-right text-blue-600 mr-2"></i> 自动类型转换（Widening Conversion）
                        </h3>
                        <p class="text-gray-700">将小范围的数值类型转换为大范围的数值类型，例如 <code class="bg-blue-100 px-1 py-0.5 rounded">int</code> 到 <code class="bg-blue-100 px-1 py-0.5 rounded">long</code>。</p>
                        <div class="mt-4 p-4 bg-white rounded-lg">
                            <pre class="text-sm text-gray-800"><code>int i = 100;
long l = i;  // 自动类型转换

float f = l;  // 自动类型转换</code></pre>
                        </div>
                        <div class="mt-4 text-sm text-blue-600">
                            <p class="font-medium">转换方向：</p>
                            <p>byte → short → int → long → float → double</p>
                            <p>char → int → long → float → double</p>
                        </div>
                    </div>
                    <div class="bg-blue-50 p-6 rounded-lg">
                        <h3 class="text-xl font-bold text-blue-700 mb-4 flex items-center">
                            <i class="fas fa-compress-alt text-blue-600 mr-2"></i> 强制类型转换（Narrowing Conversion）
                        </h3>
                        <p class="text-gray-700">将大范围的数值类型转换为小范围的数值类型，这种转换需要使用显式的类型转换语法（<code class="bg-blue-100 px-1 py-0.5 rounded">cast</code>），例如 <code class="bg-blue-100 px-1 py-0.5 rounded">double</code> 到 <code class="bg-blue-100 px-1 py-0.5 rounded">int</code>。</p>
                        <div class="mt-4 p-4 bg-white rounded-lg">
                            <pre class="text-sm text-gray-800"><code>double d = 100.04;
int i = (int) d;  // 强制类型转换，结果为100

long l = 1000;
byte b = (byte) l;  // 强制类型转换</code></pre>
                        </div>
                        <div class="mt-4 text-sm text-red-600">
                            <p class="font-medium">注意：强制类型转换可能导致精度丢失或数据溢出！</p>
                        </div>
                    </div>
                </div>
                
                <div class="mt-8 bg-blue-50 p-6 rounded-lg">
                    <h3 class="text-xl font-bold text-blue-700 mb-4">对象类型转换</h3>
                    <p class="text-gray-700 mb-4">引用类型之间也可以进行类型转换，包括向上转型（Upcasting）和向下转型（Downcasting）。</p>
                    
                    <div class="grid md:grid-cols-2 gap-6">
                        <div>
                            <h4 class="font-bold text-blue-600 mb-2">向上转型 (自动)</h4>
                            <p class="text-sm text-gray-700">将子类对象赋值给父类引用变量</p>
                            <div class="mt-2 p-3 bg-white rounded-lg">
                                <pre class="text-xs text-gray-800"><code>Animal animal = new Dog();  // Dog是Animal的子类</code></pre>
                            </div>
                        </div>
                        <div>
                            <h4 class="font-bold text-blue-600 mb-2">向下转型 (强制)</h4>
                            <p class="text-sm text-gray-700">将父类引用变量转换为子类类型</p>
                            <div class="mt-2 p-3 bg-white rounded-lg">
                                <pre class="text-xs text-gray-800"><code>if (animal instanceof Dog) {
    Dog dog = (Dog) animal;
}</code></pre>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>
    </main>

    <!-- Footer -->
    <footer class="bg-gray-900 text-gray-300 py-8">
        <div class="container mx-auto max-w-5xl px-4 md:px-0">
            <div class="flex flex-col md:flex-row justify-between items-center">
                <div class="mb-4 md:mb-0">
                    <h3 class="text-xl font-bold text-white mb-2">技术小馆</h3>
                    <a href="http://www.yuque.com/jtostring" class="footer-link hover:text-white flex items-center">
                        <i class="fas fa-external-link-alt mr-2"></i>
                        <span>http://www.yuque.com/jtostring</span>
                    </a>
                </div>
                <div class="flex space-x-6">
                    <a href="#" class="footer-link hover:text-white">
                        <i class="fab fa-github text-xl"></i>
                    </a>
                    <a href="#" class="footer-link hover:text-white">
                        <i class="fab fa-weixin text-xl"></i>
                    </a>
                    <a href="#" class="footer-link hover:text-white">
                        <i class="fab fa-twitter text-xl"></i>
                    </a>
                </div>
            </div>
            <div class="mt-8 pt-6 border-t border-gray-800 text-center text-sm text-gray-500">
                © 2023 技术小馆. 保留所有权利。
            </div>
        </div>
    </footer>

    <script>
        // 初始化Mermaid图表
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: false,
                htmlLabels: true,
                curve: 'basis'
            }
        });
        
        // 简单的滚动动画
        document.querySelectorAll('a[href^="#"]').forEach(anchor => {
            anchor.addEventListener('click', function (e) {
                e.preventDefault();
                document.querySelector(this.getAttribute('href')).scrollIntoView({
                    behavior: 'smooth'
                });
            });
        });
    </script>
</body>
</html>
```